package com.oa.xinxi.biz;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.oa.xinxi.dao.RulesMapper;
import com.oa.xinxi.entity.Rules;

@Service
public class RulesBiz {
	@Resource
	private RulesMapper rulesMapper;
	public void save(Rules rules) {
		rules.setCreatetime(new Date());
		rulesMapper.insert(rules);
	}
	public void deleteById(Integer id) {
		rulesMapper.deleteByPrimaryKey(id);
	}
	public void update(Rules rules) {
		rules.setUpdateTime(new Date());
		Rules rules2 = rulesMapper.selectByPrimaryKey(rules.getRulesId());
		rules.setCreatetime(rules2.getCreatetime());
		rules.setCreator(rules2.getCreator());
		rulesMapper.updateByPrimaryKeySelective(rules);
	}
	public Rules findById(Integer id) {
		return rulesMapper.selectByPrimaryKey(id);
	}
	public List<Rules> findAll() {
		return rulesMapper.findAll();
	}
}
